import requests
from config import url,headers_wechat

class ClassesGet:
    def __int__(self):
        self.url = url
        self.headers = headers_wechat

    @classmethod
    def classes_info(cls,url: str, params=None,headers= headers_wechat):
        '''
        @Summary:获取班级信息
        @Description:小程序获取班级信息
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/classes"
        r = requests.get(url= url,headers= headers,params=params)
        return r

    @classmethod
    def classes_major(cls,url : str,params= None,headers= headers_wechat):
        '''
        @Summary:获取专业信息
        @Description:小程序获取专业信息
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/classes/major"
        r = requests.get(url= url,headers= headers,params= params)
        return r

    @classmethod
    def classes_year(cls,url : str,params= None,headers = headers_wechat):
        '''
        @Summary:获取年级信息
        @Description:小程序获取年级信息
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/classes/year"
        r = requests.get(url=url, headers=headers, params=params)
        return r
class ClassesPost:
    def __int__(self):
        self.url = url
        self.headers = headers_wechat

    @classmethod
    def courseTables_page(cls,url : str,json= None,params = None,headers= headers_wechat):
        '''
        @Summary:班级课表查询
        @Description:小程序获取年级信息
        :param url:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/classes/coursetables/page"
        r = requests.post(url= url,headers=headers,params=params,json=json)
        return r

    @classmethod
    def courseTables_statistics(self,url :str,json= None,params = None,headers= headers_wechat):
        '''
        @Summary:班级课表查询统计接口
        @Description:小程序班级课表查询统计接口
        :param url:
        :param json:
        :param params:
        :return:
        '''
        url = url + "/courseApi/v1/classes/coursetables/statistics"
        r = requests.post(url=url, headers=headers, params=params, json=json)
        return r

if __name__ == '__main__':
    from common.hashlib_utils import hash_md5

    valid_code = hash_md5("&signKey=123123")
    # resp = ClassesPost.courseTables_page(url, params={"validCode": valid_code},json={
    #     "weekNum":"",
    #     "majorId":"",
    #     "week":"",
    #     "year":"",
    #     "collegeId":"",
    #     "segment":"",
    #     "administrativeClass":"",
    #     "page":"",
    #     "rows":""
    # })
    resp = ClassesGet.classes_info(url,params={"validCode": valid_code})
    print(resp.url, "\n", resp, resp.content)
    print(resp.request.headers, "\n", resp.request.method)
